<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>码段</title>
    <!-- CSS -->
    <jsp:include page="../include/headtag.jsp" />
    <!-- <link rel="stylesheet"
        href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> -->
    <link rel="stylesheet"
          href="assets/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/form-elements.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <%
        /********** 保存网站的基本路径 ***********/
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + path + "/";
        //将该路径地址缓存到 session中 ,例如：http://localhost:8090/tjnu_ssh_1128/
        session.setAttribute("mybasePath", basePath);
    %>
</head>
<body>
<jsp:include page="../include/head.jsp" />
<jsp:include page="../include/menu.jsp" />
<div id="page-wrapper" style="margin-top: 50px;">
    <div id="page-inner">

        <div class="text-left">
            <a href="/index">首页</a>&nbsp;&gt;&nbsp;<a href="/auditing" class="acts CurrChnlCls">编码审核</a>&nbsp;&gt;&nbsp;<a  class="acts CurrChnlCls">待审核列表</a> &nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">整体审核</a> &nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">非枚举审核</a>&nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">枚举审核</a>
        </div>

        <div class="row">
            <div class="col-md-12">
                <h3 class="text-left">枚举审核</h3>
                <div class="col-md-12">
                    <div class="nav navbar-nav navbar-right">
                        <a href="">枚举审核</a>
                    </div>
                </div>
            </div>
        </div>
        <hr />
        <br />
        <div class="container-fluid">
            <c:choose>
        <c:when test="${fn:length(enums)==0}">
            <h3 align="center">Oops,该规则没有枚举类型...</h3>
            <br><br><br>
        </c:when>
            <c:otherwise>
            <c:forEach var="Enum" items="${enums}" varStatus="s">

                <form class="form-horizontal  table-bordered" role="form">
                    <fieldset>
                        <legend>枚举码段${s.count}</legend>
                        <h5 align="left">基本信息</h5>
                        <br><br>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="seg_name${s.count}">码段名称</label>
                            <div class="col-sm-9">
                                <input class="form-control" type="text" id="seg_name${s.count}" size="10" value="${Enum.details}" readonly />
                            </div>
                        </div>
                        <br><br>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="seg_kind${s.count}">码段选项</label>
                            <div class="col-sm-9">
                                <input class="form-control" type="text" id="seg_options${s.count}" size="10" value="${Enum.options}" readonly/>
                            </div>
                        </div>

                        <br><br>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="seg_kind${s.count}">选项编号</label>
                            <div class="col-sm-9">
                                <input class="form-control" type="text" id="seg_kind${s.count}" size="10" value="${Enum.optionsDig}" readonly/>
                            </div>
                        </div>

                        <br><br>

                        <br><br>
                        <hr style="margin:0px;background-color:#eee;height:0.5px;border:none;" />
                        <h5 align="left">枚举审核</h5>


                        <br>

                        <div class="form-group">
                            <div class="form-horizontal">
                                <label class="col-sm-2 control-label" for="Bot_Advise${s.count}">审核意见:</label>

                                <div class="col-lg-9">
                                <textarea id="Bot_Advise${s.count}" class="form-control"
                                          style="resize: none;
                                      LINE-HEIGHT:18px;padding: 3px;width:100%;height:100px;max-width:100%;max-height: 100px;"></textarea>
                            </div>
                        </div>
                        </div>

                        <div class="form-group">
                            <div class="form-horizontal">
                                <div class="col-lg-2 col-lg-push-3" >
                                    <input type=radio name="pass${s.count}" id="wdx_pass" style="zoom:150%;" value=1>
                                    <label for="wdx_pass">通过</label>
                                </div>

                                <div class="col-lg-2 col-lg-push-6">
                                    <input type=radio name="pass${s.count}" id="wdx_unpass" style="zoom:150%;" value=0>
                                    <label for="wdx_unpass">不通过</label>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                </form>

                <br>
                <br>


                <div class="row">

                    <a type="submit" class="col-lg-3 btn btn-default btn-sm col-lg-push-3" value="submit"  onclick="clear_bot(${s.count})">清除</a>
                    <a type="submit" class="col-lg-3 btn btn-primary btn-sm col-lg-push-4" value="save"  onclick="save_bot(${s.count})">保存</a>

                </div>

                <br>
                <br>
                <hr style="border-top:1px dashed #0066CC;"/>
                <br>
                <br>

            </c:forEach>
            </c:otherwise>
            </c:choose>
            <div class="row">
            <a type="submit" class="col-lg-4 btn btn-info btn-sm col-lg-push-4" value="submit"  onclick="redir_to_info()">下一步</a>
            </div>
        </div>



    </div>
    <!-- /. PAGE INNER  -->
</div>
<!-- /. PAGE WRAPPER  -->

</body>
<!-- Javascript -->
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap/js/jquery.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>

<script type="text/javascript">
    function clear_bot(id){
        var radio_name = "pass"+id;
        $(":radio[name='" +radio_name +"']:checked").attr("checked", false);
        $("#Bot_Advise"+id).val("");
        alert("清除成功！");
    }
</script>

<script type="text/javascript">
    window.onload = function () {
        is_save = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    }
</script>

<script type="text/javascript">
    function redir_to_info() {
        for(var i =1 ;i <=${fn:length(enums)};i++){
            if(is_save[i]==0){
                alert("请先保存码段"+i+"的相关审核操作!");
                return false;
            }
        }
        var record_id = ${record.codeRuleManageId};
        window.location.href = "/auditingInfo?id="+record_id;
    }
</script>

<script type="text/javascript">

    function save_bot(id){

        var radio_name = "pass"+id;
        var is_pass = $(":radio[name='" +radio_name+"']:checked").val();

        if(is_pass==null){
            alert("请选择码段"+id+"是否通过审核！");
            return false;
        }

        if($("#Bot_Advise"+id).val()==""){
            alert("请输入码段"+id+"的审核意见！");
            return false;
        }

        alert("保存成功！");
        is_save[id]=1;

        var url = "/auditingBot";
        var params = {
            "id":0,
            "ruleId":${rule.codeRuleId},
            "segName":$("#seg_name"+id).val(),
            "botAdvise":$("#Bot_Advise"+id).val(),
            "isPass":is_pass,
            "op":${record.manageOperation},
        };
        $.ajax({
            url:url,
            data:JSON.stringify(params),
            type:"post",
            success:function (resultData) {
                console.log("success");
            },
            dataType:"json",
            contentType: 'application/json',
        });
    }
</script>

</html>
